﻿using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace FriendStar.Application.BOM
{
    public class DrawReport
    {
        public void Draw(Image picFA, string MaterialSizes, string MaterialSizes_J, string RoughsSize, string RoughsType,string realPath)
         {
            int RecC = 0, RecK = 0, RecJC = 0, RecJK = 0;

            int sCX1 = 0, sCX2 = 0, sCX3 = 0, sCX4 = 0, sCX5 = 0;

            int sCY1 = 0, sCY2 = 0, sCY3 = 0, sCY4 = 0, sCY5 = 0;

            RecK = (int)decimal.Parse(MaterialSizes.Substring(6, 4));

            RecC = (int)decimal.Parse(MaterialSizes.Substring(11, 5));

            RecJK = (int)decimal.Parse(MaterialSizes_J.Substring(0, 6));

            RecJC = (int)decimal.Parse(MaterialSizes_J.Substring(MaterialSizes_J.Length - 6));

            int ssJQGGJS = 1;

            string ssMPCC = RoughsSize;

            string ssCLGG = MaterialSizes;

            string ssJQGG = MaterialSizes_J;

            string MpK = "1";

            string MpC = "1";
        
            int MPjs = ssMPCC.IndexOf("/");

            if (MPjs != -1)
            {
                string[] MpStr = ssMPCC.Substring(0, MPjs).Split('x');
                MpK = MpStr[0].ToString();
                MpC = MpStr[1].ToString();
            }
            else
            {
                string[] MpStr = ssMPCC.Split('x');
                MpK = MpStr[0].ToString();
                MpC = MpStr[1].ToString();
            }
            try
            {
                if (decimal.Parse(MpC) == 0)
                {
                    ssJQGGJS = 1;
                }
                else
                {
                    ssJQGGJS = (int)(decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6)) / decimal.Parse(MpC));
                    ssJQGGJS = ssJQGGJS == 0 ? 1 : ssJQGGJS;
                }
            }
            catch
            {

            }
            if (int.Parse(ssCLGG.Substring(6, 4)) >= int.Parse(ssCLGG.Substring(12, 4)))
            {
                sCX1 = 50;
                sCY1 = 50;
                sCX2 = RecC;
                sCY2 = RecK;
            }
            else
            {
                sCX1 = 50;
                sCY1 = 50;
                sCX2 = RecC;
                sCY2 = RecK;
            }

            decimal ProduNumber = 1;//可制件数

            decimal ProduNumber_Z = 1;//制件总数

            string YLGG1 = "", YLGG2 = "";

            int FA1_KDSL = 0, FA1_CDSL = 0, FA1_KDYL = 0, FA1_CDYL = 0, FA1_GBZS = 1;

            int FA2_KDSL = 0, FA2_CDSL = 0, FA2_KDYL = 0, FA2_CDYL = 0, FA2_GBZS = 1;

            string FA1_YLGG1, FA1_YLGG2, FA2_YLGG1, FA2_YLGG2;

            g.FillRectangle(Brushes.White, new Rectangle(0, 0, picFA.Width, picFA.Height));

            if (RoughsType == "K")
            {
                //按毛坯宽度与板料宽度一致的方向进行排样 --- 方案一
                FA1_KDSL = (int)decimal.Parse(ssCLGG.Substring(6, 4)) / (int)decimal.Parse(ssJQGG.Substring(0, 6));
                FA1_CDSL = (int)decimal.Parse(ssCLGG.Substring(12, 4)) / (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));

                if ((FA1_KDSL > 0) && (FA1_CDSL > 0))
                {
                    FA1_KDYL = (int)decimal.Parse(ssCLGG.Substring(6, 4)) - FA1_KDSL * (int)decimal.Parse(ssJQGG.Substring(0, 6));
                    FA1_CDYL = (int)decimal.Parse(ssCLGG.Substring(12, 4)) - FA1_CDSL * (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));
                    string KDStr = "    " + string.Format("{0:N0}", FA1_KDYL);
                    string CDStr = "    " + string.Format("{0:N0}", FA1_CDYL);
                    FA1_YLGG1 = FA1_KDYL == 0 ? "" : (KDStr.Substring(KDStr.Length - 4) + "x" + ssCLGG.Substring(12, 4));
                    FA1_YLGG2 = FA1_CDYL == 0 ? "" : (ssCLGG.Substring(6, 4) + "x" + CDStr.Substring(CDStr.Length - 4));
                    // FA1_GBZS = (int)(ZJZS / (FA1_KDSL * FA1_CDSL * ssJQGGJS)) == (int)(ZJZS / (FA1_KDSL * FA1_CDSL * ssJQGGJS)) ? (int)(ZJZS / (FA1_KDSL * FA1_CDSL * ssJQGGJS)) : (int)((ZJZS / (FA1_KDSL * FA1_CDSL * ssJQGGJS)) + 1);


                    YLGG1 = FA1_YLGG1;
                    YLGG2 = FA1_YLGG2;
                    ProduNumber = FA1_KDSL * FA1_CDSL * ssJQGGJS;//可制件数
                    ProduNumber_Z = FA1_GBZS * FA1_KDSL * FA1_CDSL * ssJQGGJS;//制件总数

                    int YLSL1 = 0, YLSL2 = 0;
                    YLSL1 = FA1_YLGG1 == "" ? 0 : FA1_CDSL * FA1_GBZS;
                    YLSL2 = FA1_YLGG2 == "" ? 0 : FA1_GBZS;
                    sCX3 = (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));
                    sCY3 = (int)decimal.Parse(ssJQGG.Substring(0, 6));

                    sCX4 = (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));
                    sCY4 = FA1_KDSL * (int)decimal.Parse(ssJQGG.Substring(0, 6));

                    sCX5 = FA1_CDSL * (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));
                    sCY5 = (int)decimal.Parse(ssJQGG.Substring(0, 6));
                }
            }
            else
            {
                //按毛坯长度与板料宽度一致的方向进行排样 --- 方案二
                FA2_KDSL = (int)decimal.Parse(ssCLGG.Substring(6, 4)) / (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));
                FA2_CDSL = (int)decimal.Parse(ssCLGG.Substring(12, 4)) / (int)decimal.Parse(ssJQGG.Substring(0, 6));

                if ((FA2_KDSL > 0) && (FA2_CDSL > 0))
                {
                    FA2_KDYL = (int)decimal.Parse(ssCLGG.Substring(6, 4)) - FA2_KDSL * (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));
                    FA2_CDYL = (int)decimal.Parse(ssCLGG.Substring(12, 4)) - FA2_CDSL * (int)decimal.Parse(ssJQGG.Substring(0, 6));
                    string KDStr2 = "    " + string.Format("{0:N0}", FA2_KDYL);
                    string CDStr2 = "    " + string.Format("{0:N0}", FA2_CDYL);
                    FA2_YLGG1 = FA2_KDYL == 0 ? "" : (KDStr2.Substring(KDStr2.Length - 4) + "x" + ssJQGG.Substring(ssJQGG.Length - 6));
                    FA2_YLGG2 = FA2_CDYL == 0 ? "" : (ssCLGG.Substring(6, 4) + "x" + CDStr2.Substring(CDStr2.Length - 4));

                    ProduNumber = FA2_KDSL * FA2_CDSL * ssJQGGJS;//可制件数
                    ProduNumber_Z = FA2_GBZS * FA2_KDSL * FA2_CDSL * ssJQGGJS;//制件总数

                    int YLSL1 = 0, YLSL2 = 0;
                    YLSL1 = FA2_YLGG1 == "" ? 0 : FA2_CDSL * FA2_GBZS;
                    YLSL2 = FA2_YLGG2 == "" ? 0 : FA2_GBZS;

                    sCX3 = (int)decimal.Parse(ssJQGG.Substring(0, 6));
                    sCY3 = (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));

                    sCX4 = (int)decimal.Parse(ssJQGG.Substring(0, 6));
                    sCY4 = FA2_KDSL * (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));

                    sCX5 = FA2_CDSL * (int)decimal.Parse(ssJQGG.Substring(0, 6));
                    sCY5 = (int)decimal.Parse(ssJQGG.Substring(ssJQGG.Length - 6));
                }
            }

            //自定义带箭头的笔
            Pen p = new Pen(Color.Black, 1);
            Font font = new Font("宋体", 9);
            //int X1 = 50, Y1 = 50, X2 = picFA.Width - 100, Y2 = (picFA.Width - 100) / (RecC / RecK);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            #region
            if (sCX2 > sCY2)
            {
                if ((sCX2 * (picFA.Height - 100) / sCY2) > 1000)
                {
                    g.DrawRectangle(p, sCX1, sCY1, sCX2 * 800 / sCX2, sCY2 * 800 / sCX2);
                    if ((sCY2 - sCY4) < 50)
                    {
                        Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * 800 / sCX2, (sCY2 - sCY4) * 800 / sCX2);
                        g.DrawRectangle(p, sCX1, sCY1, sCX5 * 800 / sCX2, (sCY2 - sCY4) * 800 / sCX2);
                        HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                        g.FillRectangle(aa, rect);//填充这个矩形
                        g.DrawRectangle(p, sCX1 + sCX5 * 800 / sCX2, sCY1, (sCX2 - sCX5) * 800 / sCX2, sCY2 * 800 / sCX2);//长度方向余料
                        Rectangle rect2 = new Rectangle(sCX1 + sCX5 * 800 / sCX2, sCY1, (sCX2 - sCX5) * 800 / sCX2, sCY2 * 800 / sCX2);
                        HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                        g.FillRectangle(aa2, rect2);//填充这个矩形
                    }
                    else
                    {
                        if (sCX5 < sCX2 && (sCX2 - sCX5) > (sCY2 - sCY4))
                        {
                            Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * 800 / sCX2, (sCY2 - sCY4) * 800 / sCX2);

                            g.DrawRectangle(p, sCX1, sCY1, sCX5 * 800 / sCX2, (sCY2 - sCY4) * 800 / sCX2);

                            HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa, rect);

                            g.DrawRectangle(p, sCX1 + sCX5 * 800 / sCX2, sCY1, (sCX2 - sCX5) * 800 / sCX2, sCY2 * 800 / sCX2);//长度方向余料

                            Rectangle rect2 = new Rectangle(sCX1 + sCX5 * 800 / sCX2, sCY1, (sCX2 - sCX5) * 800 / sCX2, sCY2 * 800 / sCX2);

                            HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa2, rect2);
                        }
                        else
                        {
                            Rectangle rect = new Rectangle(sCX1, sCY1, sCX2 * 800 / sCX2, (sCY2 - sCY4) * 800 / sCX2);

                            g.DrawRectangle(p, sCX1, sCY1, sCX2 * 800 / sCX2, (sCY2 - sCY4) * 800 / sCX2);

                            HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa, rect);

                            g.DrawRectangle(p, sCX1 + sCX5 * 800 / sCX2, sCY1 + (sCY2 - sCY4) * 800 / sCX2, (sCX2 - sCX5) * 800 / sCX2, (sCY4) * 800 / sCX2);//长度方向余料

                            Rectangle rect2 = new Rectangle(sCX1 + sCX5 * 800 / sCX2, sCY1 + (sCY2 - sCY4) * 800 / sCX2, (sCX2 - sCX5) * 800 / sCX2, sCY4 * 800 / sCX2);

                            HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa2, rect2);
                        }
                    }
                    if ((sCY3 * 800 / sCX2) < 20 && (sCY2 * 800 / sCX2) > 20)
                    {
                        if ((sCX3 * 800 / sCX2) < 50 && (sCX5 * 800 / sCX2) > 50)
                        {
                            //剪切毛坯
                            g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * 800 / sCX2 - 20), 50, 20);
                            if ((sCY2 - sCY4) < 50)
                            {
                                //剪切划线
                                g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * 800 / sCX2);
                            }
                            else
                            {
                                g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * 800 / sCX2, sCX1 + 50, sCY1 + sCY2 * 800 / sCX2);//剪切划线
                            }
                        }
                        else
                        {
                            //剪切毛坯
                            g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * 800 / sCX2 - 20), sCX3 * 800 / sCX2, 20);

                            if ((sCY2 - sCY4) < 50)
                            {
                                g.DrawLine(p, sCX1 + sCX3 * 800 / sCX2, sCY1, sCX1 + sCX3 * 800 / sCX2, sCY1 + sCY2 * 800 / sCX2);//剪切划线
                            }
                            else
                            {
                                g.DrawLine(p, sCX1 + sCX3 * 800 / sCX2, sCY1 + (sCY2 - sCY4) * 800 / sCX2, sCX1 + sCX3 * 800 / sCX2, sCY1 + sCY2 * 800 / sCX2);//剪切划线
                            }
                        }
                    }
                    else
                    {
                        if ((sCX3 * 800 / sCX2) < 50 && (sCX5 * 800 / sCX2) > 50)
                        {
                            //剪切毛坯
                            g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * 800 / sCX2, 50, sCY3 * 800 / sCX2);

                            if ((sCY2 - sCY4) < 50)
                            {
                                //剪切划线
                                g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * 800 / sCX2);
                            }
                            else
                            {
                                g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * 800 / sCX2, sCX1 + 50, sCY1 + sCY2 * 800 / sCX2);//剪切划线
                            }
                        }
                        else
                        {
                            g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * 800 / sCX2, sCX3 * 800 / sCX2, sCY3 * 800 / sCX2);//剪切毛坯

                            if ((sCY2 - sCY4) < 50)
                            {
                                g.DrawLine(p, sCX1 + sCX3 * 800 / sCX2, sCY1, sCX1 + sCX3 * 800 / sCX2, sCY1 + sCY2 * 800 / sCX2);//剪切划线
                            }
                            else
                            {
                                g.DrawLine(p, sCX1 + sCX3 * 800 / sCX2, sCY1 + (sCY2 - sCY4) * 800 / sCX2, sCX1 + sCX3 * 800 / sCX2, sCY1 + sCY2 * 800 / sCX2);//剪切划线
                            }
                        }
                    }
                    //定义单色画刷
                    SolidBrush b1 = new SolidBrush(Color.Black);
                   ////标注剪切尺寸
                    g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * 800 / sCX2 / 2 - 15, sCY1 + sCY2 * 800 / sCX2 + 5));
                    if ((sCY3 * 800 / sCX2) < 20 && (sCY2 * 800 / sCX2) > 20)
                    {
                        g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * 800 / sCX2 / 2 - 5, sCY1 + (sCY2 - sCY3) * 800 / sCX2 + sCY3 * 800 / sCX2 / 2 - 5));

                        g.DrawString(sCY3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 10, sCY1 + (sCY2 - sCY3) * 800 / sCX2 + sCY3 * 800 / sCX2 / 2));
                    }
                    else
                    {
                        g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * 800 / sCX2 / 2 - 5, sCY1 + (sCY2 * 800 / sCX2 - 20 + 5)));

                        g.DrawString(sCY3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 10, sCY1 + (sCY2 * 800 / sCX2 - 20 + 5)));
                    }

                    if ((sCY2 - sCY4 != 0))
                    {
                        //宽度方向尺寸
                        g.DrawString((sCY2 - sCY4).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 5, sCY1 + (sCY2 - sCY4) * 800 / sCX2 / 2));
                    }
                    if ((sCX2 - sCX5 != 0))
                    {
                        //长度方向尺寸
                        g.DrawString((sCX2 - sCX5).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX5 * 800 / sCX2 + (sCX2 - sCX5) * 800 / sCX2 / 2 - 5, sCY1 + sCY2 * 800 / sCX2 + 5));
                    }
                    //标注长
                    if (RoughsType == "K")
                    {
                        if (FA1_KDSL > 1)
                        {
                            if (sCY2 - sCY4 > 0)
                            {
                                g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1 + sCY2 * 800 / sCX2 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                            else
                            {
                                g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1 + sCY2 * 800 / sCX2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                        }
                        else
                        {
                            if (sCY2 - sCY4 > 0)
                            {
                                g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1 + sCY2 * 800 / sCX2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                            else
                            {
                                g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                        }
                        if (FA1_CDSL > 1)
                        {
                            if (sCX2 - sCX5 > 0)
                            {
                                g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 50, sCY1 - 15));
                            }
                            else
                            {
                                g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 25, sCY1 - 15));
                            }
                        }
                        else
                        {
                            if (sCX2 - sCX5 > 0)
                            {
                                g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 50, sCY1 - 15));
                            }
                            else
                            {
                                g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 5, sCY1 - 15));
                            }
                            //g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 5, sCY1 - 15));
                        }
                    }
                    else
                    {
                        if (FA2_KDSL > 1)
                        {
                            if (sCY2 - sCY4 > 0)
                            {
                                g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1 + sCY2 * 800 / sCX2 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                            else
                            {
                                g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1 + sCY2 * 800 / sCX2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                        }
                        else
                        {
                            if (sCY2 - sCY4 > 0)
                            {
                                g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1 + sCY2 * 800 / sCX2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                            else
                            {
                                g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 + 5, sCY1 + sCY2 * 800 / sCX2 / 2), new StringFormat(StringFormatFlags.DirectionVertical));
                            }
                        }
                        if (FA2_CDSL > 1)
                        {
                            if (sCX2 - sCX5 > 0)
                            {
                                g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 50, sCY1 - 15));
                            }
                            else
                            {
                                g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 25, sCY1 - 15));
                            }
                        }
                        else
                        {
                            if (sCX2 - sCX5 > 0)
                            {
                                g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 50, sCY1 - 15));
                            }
                            else
                            {
                                g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 5, sCY1 - 15));
                            }
                            //g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 800 / sCX2 / 2 - 5, sCY1 - 15));
                        }
                    }
                    if (RoughsType == "K")
                    {
                        if (FA1_CDSL > 1)
                        {
                            g.DrawString("切" + FA1_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * 800 / sCX2 + (sCX2 - sCX3) * 800 / sCX2 / 2 - 5, sCY1 + sCY2 * 800 / sCX2 / 2));
                        }
                        if (FA1_KDSL > 1)
                        {
                            if (sCX3 * 800 / sCX2 / 2 - 15 > 0)
                            {
                                g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * 800 / sCX2 / 2 - 15, (sCY1 + sCY2 * 800 / sCX2) / 2));
                            }
                            else
                            {
                                g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * 800 / sCX2) / 2));
                            }
                        }
                    }
                    else
                    {
                        if (FA2_CDSL > 1)
                        {
                            g.DrawString("切" + FA2_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * 800 / sCX2 + (sCX2 - sCX3) * 800 / sCX2 / 2 - 5, sCY1 + sCY2 * 800 / sCX2 / 2));
                        }
                        if (FA2_KDSL > 1)
                        {
                            if (sCX3 * 800 / sCX2 / 2 - 15 > 0)
                            {
                                g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * 800 / sCX2 / 2 - 15, (sCY1 + sCY2 * 800 / sCX2) / 2 + 5));
                            }
                            else
                            {
                                g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * 800 / sCX2) / 2 + 5));
                            }
                        }
                    }
                }
                else
                {
                    #region 长度大于宽度
                    if (sCX2 * (picFA.Height - 100) / sCY2 > 600)
                    {
                        g.DrawRectangle(p, sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);
                        if ((sCY2 - sCY4) < 50)
                        {
                            Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10);

                            g.DrawRectangle(p, sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10);

                            HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa, rect);

                            g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 * 8 / 10, sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//长度方向余料

                            Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 * 8 / 10, sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);

                            HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa2, rect2);
                        }
                        else
                        {
                            if (sCX5 < sCX2 && (sCX2 - sCX5) > (sCY2 - sCY4))
                            {
                                Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10);

                                g.DrawRectangle(p, sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10);

                                HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa, rect);

                                g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 * 8 / 10, sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//长度方向余料

                                Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 * 8 / 10, sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);

                                HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa2, rect2);
                            }
                            else
                            {
                                Rectangle rect = new Rectangle(sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10);

                                g.DrawRectangle(p, sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10);

                                HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa, rect);

                                g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 * 8 / 10, sCY4 * (picFA.Height - 100) / sCY2 * 8 / 10);//长度方向余料

                                Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 * 8 / 10, sCY4 * (picFA.Height - 100) / sCY2 * 8 / 10);

                                HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa2, rect2);
                            }
                        }
                        if ((sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10) < 20 && (sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10) > 20)
                        {
                            if ((sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10) < 50 && (sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10) > 50)
                            {
                                //剪切毛坯
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10), 50, 20);

                                if ((sCY2 - sCY4) < 50)
                                {
                                    //剪切划线
                                    g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切划线
                                }
                            }
                            else
                            {
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10), sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, 20);//剪切毛坯

                                if ((sCY2 - sCY4) < 50)
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切划线
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切划线
                                }
                            }
                        }
                        else
                        {
                            if ((sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10) < 50 && (sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10) > 50)
                            {
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 * 8 / 10, 50, sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10 + 2);// sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切毛坯
                                if ((sCY2 - sCY4) < 50)
                                {
                                    g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切划线
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切划线
                                }
                            }
                            else
                            {
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 * 8 / 10, sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10 + 2);// sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切毛坯
                                if ((sCY2 - sCY4) < 50)
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切划线
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10, sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10);//剪切划线
                                }
                            }
                        }
                        //定义单色画刷
                        SolidBrush b1 = new SolidBrush(Color.Black);
                       //标注剪切尺寸
                        g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 15, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5));
                        if ((sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10) < 20 && (sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10) > 20)
                        {
                            g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 - 20) + 5));
                        }
                        else
                        {
                            g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 * 8 / 10 + sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5));
                        }
                        g.DrawString(sCY3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 10, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 * 8 / 10 + sCY3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2));
                        if ((sCY2 - sCY4 != 0))
                        {
                            //宽度方向尺寸
                            g.DrawString((sCY2 - sCY4).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 5, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 * 8 / 10 / 2));
                        }
                        if ((sCX2 - sCX5 != 0))
                        {
                            //长度方向尺寸
                            g.DrawString((sCX2 - sCX5).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX5 * (picFA.Height - 100) / sCY2 * 8 / 10 + (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5));
                        }
                        //标注长
                        //g.DrawString(sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2*8/10 / 2 - 5, sCY1 - 15));
                        if (RoughsType == "K")
                        {
                            if (FA1_KDSL > 1)
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            else
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            if (FA1_CDSL > 1)
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 25, sCY1 - 15));
                                }
                            }
                            else
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5, sCY1 - 15));
                                }
                            }
                        }
                        else
                        {
                            if (FA2_KDSL > 1)
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            else
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            if (FA2_CDSL > 1)
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 25, sCY1 - 15));
                                }
                            }
                            else
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5, sCY1 - 15));
                                }
                            }
                        }
                        if (RoughsType == "K")
                        {
                            if (FA1_CDSL > 1)
                            {
                                g.DrawString("切" + FA1_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 + (sCX2 - sCX3) * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2));
                            }
                            if (FA1_KDSL > 1)
                            {
                                if (sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 15 > 0)
                                {
                                    g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 15, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10) / 2));
                                }
                                else
                                {
                                    g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10) / 2));
                                }
                            }
                        }
                        else
                        {
                            if (FA2_CDSL > 1)
                            {
                                g.DrawString("切" + FA2_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 + (sCX2 - sCX3) * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2));
                            }
                            if (FA2_KDSL > 1)
                            {
                                if (sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 15 > 0)
                                {
                                    g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 * 8 / 10 / 2 - 15, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10) / 2));
                                }
                                else
                                {
                                    g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2 * 8 / 10) / 2));
                                }
                                //sCY1 + sCY2 * (picFA.Height - 100) / sCY2*8/10
                            }
                        }
                    }
                    else
                    {
                        g.DrawRectangle(p, sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);
                        if ((sCY2 - sCY4) < 50)
                        {
                            Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                            g.DrawRectangle(p, sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                            HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa, rect);

                            g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);//长度方向余料

                            Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);

                            HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                            //填充这个矩形
                            g.FillRectangle(aa2, rect2);
                        }
                        else
                        {
                            if (sCX5 < sCX2 && (sCX2 - sCX5) > (sCY2 - sCY4))
                            {
                                Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                                g.DrawRectangle(p, sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                                HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa, rect);

                                g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);//长度方向余料

                                Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);

                                HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa2, rect2);
                            }
                            else
                            {
                                Rectangle rect = new Rectangle(sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                                g.DrawRectangle(p, sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                                HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa, rect);

                                g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY4 * (picFA.Height - 100) / sCY2);//长度方向余料

                                Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY4 * (picFA.Height - 100) / sCY2);

                                HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                                //填充这个矩形
                                g.FillRectangle(aa2, rect2);
                            }
                        }
                        if ((sCY3 * (picFA.Height - 100) / sCY2) < 20 && (sCY2 * (picFA.Height - 100) / sCY2) > 20)
                        {
                            if ((sCX3 * (picFA.Height - 100) / sCY2) < 50 && (sCX5 * (picFA.Height - 100) / sCY2) > 50)
                            {
                                //剪切毛坯
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 - 20), 50, 20);

                                if ((sCY2 - sCY4) < 50)
                                {
                                    //剪切划线
                                    g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                                }
                            }
                            else
                            {
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 - 20), sCX3 * (picFA.Height - 100) / sCY2, 20);//剪切毛坯

                                if ((sCY2 - sCY4) < 50)
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                                }
                            }
                        }
                        else
                        {
                            if ((sCX3 * (picFA.Height - 100) / sCY2) < 50 && (sCX5 * (picFA.Height - 100) / sCY2) > 50)
                            {
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2, 50, sCY3 * (picFA.Height - 100) / sCY2);//剪切毛坯
                                if ((sCY2 - sCY4) < 50)
                                {
                                    g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                                }
                            }
                            else
                            {
                                g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2, sCX3 * (picFA.Height - 100) / sCY2, sCY3 * (picFA.Height - 100) / sCY2);//剪切毛坯
                                if ((sCY2 - sCY4) < 50)
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                                }
                                else
                                {
                                    g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                                }
                            }
                        }
                        //定义单色画刷
                        SolidBrush b1 = new SolidBrush(Color.Black);
                         //标注剪切尺寸
                        g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 + 5));
                        if ((sCY3 * (picFA.Height - 100) / sCY2) < 20 && (sCY2 * (picFA.Height - 100) / sCY2) > 20)
                        {
                            g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 - 20) + 5));
                        }
                        else
                        {
                            g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 + sCY3 * (picFA.Height - 100) / sCY2 / 2 - 5));
                        }
                        g.DrawString(sCY3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 10, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 + sCY3 * (picFA.Height - 100) / sCY2 / 2));
                        if ((sCY2 - sCY4 != 0))
                        {
                            //宽度方向尺寸
                            g.DrawString((sCY2 - sCY4).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 5, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 / 2));
                        }
                        if ((sCX2 - sCX5 != 0))
                        {
                            //长度方向尺寸
                            g.DrawString((sCX2 - sCX5).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX5 * (picFA.Height - 100) / sCY2 + (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 + 5));
                        }
                        if (RoughsType == "K")
                        {
                            if (FA1_KDSL > 1)
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            else
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            if (FA1_CDSL > 1)
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 25, sCY1 - 15));
                                }
                            }
                            else
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 - 15));
                                }
                            }
                        }
                        else
                        {
                            if (FA2_KDSL > 1)
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            else
                            {
                                if (sCY2 - sCY4 > 0)
                                {
                                    g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                                else
                                {
                                    g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2), new StringFormat(StringFormatFlags.DirectionVertical));
                                }
                            }
                            if (FA2_CDSL > 1)
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 25, sCY1 - 15));
                                }
                            }
                            else
                            {
                                if (sCX2 - sCX5 > 0)
                                {
                                    g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                                }
                                else
                                {
                                    g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 - 15));
                                }
                            }
                        }
                        if (RoughsType == "K")
                        {
                            if (FA1_CDSL > 1)
                            {
                                g.DrawString("切" + FA1_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 + (sCX2 - sCX3) * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2));
                            }
                            if (FA1_KDSL > 1)
                            {
                                if (sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15 > 0)
                                {
                                    g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                                }
                                else
                                {
                                    g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                                }
                            }
                        }
                        else
                        {
                            if (FA2_CDSL > 1)
                            {
                                g.DrawString("切" + FA2_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 + (sCX2 - sCX3) * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2));
                            }
                            if (FA2_KDSL > 1)
                            {
                                if (sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15 > 0)
                                {
                                    g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                                }
                                else
                                {
                                    g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                                }
                            }
                        }
                    }
                    #endregion
                }

            }
            else
            {
                #region 长度小于宽度
                if ((sCY2 - sCY4) < 50)
                {
                    Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                    g.DrawRectangle(p, sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                    HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                    //填充这个矩形
                    g.FillRectangle(aa, rect);

                    g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);//长度方向余料

                    Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);

                    HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                    //填充这个矩形
                    g.FillRectangle(aa2, rect2);
                }
                else
                {
                    if (sCX5 < sCX2 && (sCX2 - sCX5) > (sCY2 - sCY4))
                    {
                        Rectangle rect = new Rectangle(sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                        g.DrawRectangle(p, sCX1, sCY1, sCX5 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                        HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                        //填充这个矩形
                        g.FillRectangle(aa, rect);

                        g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);//长度方向余料

                        Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);

                        HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                        //填充这个矩形
                        g.FillRectangle(aa2, rect2);
                    }
                    else
                    {
                        Rectangle rect = new Rectangle(sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                        g.DrawRectangle(p, sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2, (sCY2 - sCY4) * (picFA.Height - 100) / sCY2);

                        HatchBrush aa = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                        //填充这个矩形
                        g.FillRectangle(aa, rect);

                        g.DrawRectangle(p, sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY4 * (picFA.Height - 100) / sCY2);//长度方向余料

                        Rectangle rect2 = new Rectangle(sCX1 + sCX5 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, (sCX2 - sCX5) * (picFA.Height - 100) / sCY2, sCY4 * (picFA.Height - 100) / sCY2);

                        HatchBrush aa2 = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Black, Color.White);
                        //填充这个矩形
                        g.FillRectangle(aa2, rect2);
                    }
                }
                g.DrawRectangle(p, sCX1, sCY1, sCX2 * (picFA.Height - 100) / sCY2, sCY2 * (picFA.Height - 100) / sCY2);
                if ((sCY3 * (picFA.Height - 100) / sCY2) < 20 && (picFA.Height - 100) > 20)
                {
                    if ((sCX3 * (picFA.Height - 100) / sCY2) < 50 && (sCX5 * (picFA.Height - 100) / sCY2) > 50)
                    {
                        g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 - 20), 50, 20);//剪切毛坯
                        if ((sCY2 - sCY4) < 50)
                        {
                            g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                        }
                        else
                        {
                            g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                        }
                    }
                    else
                    {
                        g.DrawRectangle(p, sCX1, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 - 20), sCX3 * (picFA.Height - 100) / sCY2, 20);//剪切毛坯
                        if ((sCY2 - sCY4) < 50)
                        {
                            g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                        }
                        else
                        {
                            g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                        }
                    }
                }
                else
                {
                    if ((sCX3 * (picFA.Height - 100) / sCY2) < 50 && (sCX5 * (picFA.Height - 100) / sCY2) > 50)
                    {
                        g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2, 50, sCY3 * (picFA.Height - 100) / sCY2);//剪切毛坯
                        if ((sCY2 - sCY4) < 50)
                        {
                            g.DrawLine(p, sCX1 + 50, sCY1, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线  
                        }
                        else
                        {
                            g.DrawLine(p, sCX1 + 50, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + 50, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                        }
                    }
                    else
                    {
                        g.DrawRectangle(p, sCX1, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2, sCX3 * (picFA.Height - 100) / sCY2, sCY3 * (picFA.Height - 100) / sCY2);//剪切毛坯
                        if ((sCY2 - sCY4) < 50)
                        {
                            g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                        }
                        else
                        {
                            g.DrawLine(p, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2, sCX1 + sCX3 * (picFA.Height - 100) / sCY2, sCY1 + sCY2 * (picFA.Height - 100) / sCY2);//剪切划线
                        }
                    }
                }
                //定义单色画刷
                SolidBrush b1 = new SolidBrush(Color.Black);
                //标注剪切尺寸
                g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 + 5));

                if ((sCY3 * (picFA.Height - 100) / sCY2) < 20 && (picFA.Height - 100) > 20)
                {
                    g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + (sCY2 * (picFA.Height - 100) / sCY2 - 20) + 5));
                }
                else
                {
                    g.DrawString("W1", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 + sCY3 * (picFA.Height - 100) / sCY2 / 2 - 5));
                }

                g.DrawString(sCY3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 10, sCY1 + (sCY2 - sCY3) * (picFA.Height - 100) / sCY2 + sCY3 * (picFA.Height - 100) / sCY2 / 2));

                if ((sCY2 - sCY4 != 0))
                {
                    //宽度方向尺寸
                    g.DrawString((sCY2 - sCY4).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 / 2 - 5, sCY1 + (sCY2 - sCY4) * (picFA.Height - 100) / sCY2 / 2));
                }
                if ((sCX2 - sCX5 != 0))
                {
                    //长度方向尺寸
                    g.DrawString((sCX2 - sCX5).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX5 * (picFA.Height - 100) / sCY2 + (sCX2 - sCX5) * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 + 5));
                }
                if (RoughsType == "K")
                {
                    if (FA1_KDSL > 1)
                    {
                        if (sCY2 - sCY4 > 0)
                        {
                            g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                        else
                        {
                            g.DrawString(sCY3.ToString() + " x " + FA1_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                    }
                    else
                    {
                        if (sCY2 - sCY4 > 0)
                        {
                            g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                        else
                        {
                            g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                    }
                    if (FA1_CDSL > 1)
                    {
                        if (sCX2 - sCX5 > 0)
                        {
                            g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                        }
                        else
                        {
                            g.DrawString(sCX3.ToString() + " x " + FA1_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 25, sCY1 - 15));
                        }
                    }
                    else
                    {
                        if (sCX2 - sCX5 > 0)
                        {
                            g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                        }
                        else
                        {
                            g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 - 15));
                        }
                    }
                }
                else
                {
                    if (FA2_KDSL > 1)
                    {
                        if (sCY2 - sCY4 > 0)
                        {
                            g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 80), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                        else
                        {
                            g.DrawString(sCY3.ToString() + " x " + FA2_KDSL.ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                    }
                    else
                    {
                        if (sCY2 - sCY4 > 0)
                        {
                            g.DrawString(sCY3.ToString() + " + " + (sCY2 - sCY4).ToString() + " = " + sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2 - 50), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                        else
                        {
                            g.DrawString(sCY2.ToString(), new Font("宋体", 11), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 + 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2), new StringFormat(StringFormatFlags.DirectionVertical));
                        }
                    }
                    if (FA2_CDSL > 1)
                    {
                        if (sCX2 - sCX5 > 0)
                        {
                            g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                        }
                        else
                        {
                            g.DrawString(sCX3.ToString() + " x " + FA2_CDSL.ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 25, sCY1 - 15));
                        }
                    }
                    else
                    {
                        if (sCX2 - sCX5 > 0)
                        {
                            g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString() + " = " + sCX2.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 50, sCY1 - 15));
                        }
                        else
                        {
                            g.DrawString(sCX3.ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 - 15));
                        }
                        //g.DrawString(sCX3.ToString() + " + " + (sCX2 - sCX5).ToString(), new Font("宋体", 10), b1, new PointF(sCX1 + sCX2 * 700 / sCX2 * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 - 15));
                    }
                }
                if (RoughsType == "K")
                {
                    if (FA1_CDSL > 1)
                    {
                        g.DrawString("切" + FA1_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 + (sCX2 - sCX3) * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2));
                    }
                    if (FA1_KDSL > 1)
                    {
                        if (sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15 > 0)
                        {
                            g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                        }
                        else
                        {
                            g.DrawString("切" + FA1_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                        }
                    }
                }
                else
                {
                    if (FA2_CDSL > 1)
                    {
                        g.DrawString("切" + FA2_CDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 + (sCX2 - sCX3) * (picFA.Height - 100) / sCY2 / 2 - 5, sCY1 + sCY2 * (picFA.Height - 100) / sCY2 / 2));
                    }
                    if (FA2_KDSL > 1)
                    {
                        if (sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15 > 0)
                        {
                            g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1 + sCX3 * (picFA.Height - 100) / sCY2 / 2 - 15, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                        }
                        else
                        {
                            g.DrawString("切" + FA2_KDSL.ToString() + "块", new Font("宋体", 10), b1, new PointF(sCX1, (sCY1 + sCY2 * (picFA.Height - 100) / sCY2) / 2));
                        }
                    }
                }
                #endregion
            }
            #endregion
            font.Dispose(); //释放资源
            p.Dispose();//释放资源
        }

        public Graphics g
        {
            get;
            set;
        }
    }
}
